﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Media.Core.Helpers
{
    class MainHelper
    {
        public static bool CheckExtension(string title)
        {
            DataTable dtExtensions = Data.Connections.GetDataTable("Main_Get_ExtensionTypes");

            string[] Extensions = new string[dtExtensions.Rows.Count];
            var output = false;
            for (int i = 0; i < Extensions.Length; i++)
            {
                Extensions[i] = dtExtensions.Rows[i]["FileType"].ToString();
            }

            for (int i = 0; i < Extensions.Length; i++)
            {
                if (title.IndexOf(Extensions[i]) != -1)
                {
                    output = true;
                }
            }
            return output;

        }

        public static string RemoveExtension(string title)
        {
            DataTable dtExtensions = Data.Connections.GetDataTable("Main_Get_ExtensionTypes");

            string[] Extensions = new string[dtExtensions.Rows.Count];

            for (int i = 0; i < Extensions.Length; i++)
            {
                Extensions[i] = dtExtensions.Rows[i]["FileType"].ToString();
            }


            for (int i = 0; i < Extensions.Length; i++)
            {
                if (title.IndexOf(Extensions[i]) != -1)
                {
                    title = title.Substring(0, title.IndexOf(Extensions[i]));
                }

            }

            return title;
        }
    }
}
